package com.hyphenate.easeui.widget.emojicon.utils;

import android.content.Context;
import android.content.res.TypedArray;

import com.hyphenate.easeui.widget.emojicon.utils.EaseEmojicon.Type;
import com.rchat.pocmini.PocApplication;
import com.rchat.pocmini.R;

public class EaseDefaultEmojiconDatas {
	
	private static CharSequence[] sSmileyTextsArray; 
	private static int[] sSmileyImgsArray; 
    
    private static String[] emojis = new String[]{
        EaseSmileUtils.ee_1,
        EaseSmileUtils.ee_2,
        EaseSmileUtils.ee_3,
        EaseSmileUtils.ee_4,
        EaseSmileUtils.ee_5,
        EaseSmileUtils.ee_6,
        EaseSmileUtils.ee_7,
        EaseSmileUtils.ee_8,
        EaseSmileUtils.ee_9,
        EaseSmileUtils.ee_10,
        EaseSmileUtils.ee_11,
        EaseSmileUtils.ee_12,
        EaseSmileUtils.ee_13,
        EaseSmileUtils.ee_14,
        EaseSmileUtils.ee_15,
        EaseSmileUtils.ee_16,
        EaseSmileUtils.ee_17,
        EaseSmileUtils.ee_18,
        EaseSmileUtils.ee_19,
        EaseSmileUtils.ee_20,
        EaseSmileUtils.ee_21,
        EaseSmileUtils.ee_22,
        EaseSmileUtils.ee_23,
        EaseSmileUtils.ee_24,
        EaseSmileUtils.ee_25,
        EaseSmileUtils.ee_26,
        EaseSmileUtils.ee_27,
        EaseSmileUtils.ee_28,
        EaseSmileUtils.ee_29,
        EaseSmileUtils.ee_30,
        EaseSmileUtils.ee_31,
        EaseSmileUtils.ee_32,
        EaseSmileUtils.ee_33,
        EaseSmileUtils.ee_34,
        EaseSmileUtils.ee_35,
       
    };
    
    private static int[] icons = new int[]{
//        R.drawable.ee_1,
//        R.drawable.ee_2,
//        R.drawable.ee_3,
//        R.drawable.ee_4,
//        R.drawable.ee_5,
//        R.drawable.ee_6,
//        R.drawable.ee_7,
//        R.drawable.ee_8,
//        R.drawable.ee_9,
//        R.drawable.ee_10,
//        R.drawable.ee_11,
//        R.drawable.ee_12,
//        R.drawable.ee_13,
//        R.drawable.ee_14,
//        R.drawable.ee_15,
//        R.drawable.ee_16,
//        R.drawable.ee_17,
//        R.drawable.ee_18,
//        R.drawable.ee_19,
//        R.drawable.ee_20,
//        R.drawable.ee_21,
//        R.drawable.ee_22,
//        R.drawable.ee_23,
//        R.drawable.ee_24,
//        R.drawable.ee_25,
//        R.drawable.ee_26,
//        R.drawable.ee_27,
//        R.drawable.ee_28,
//        R.drawable.ee_29,
//        R.drawable.ee_30,
//        R.drawable.ee_31,
//        R.drawable.ee_32,
//        R.drawable.ee_33,
//        R.drawable.ee_34,
//        R.drawable.ee_35,
    };
    
    
    private static final EaseEmojicon[] DATA = createData();
    
    private static EaseEmojicon[] createData(){
    	if(sSmileyTextsArray == null){
            sSmileyTextsArray = PocApplication.getContext().getResources()
            		.getTextArray(R.array.smiley_code_array);
        }
    	
    	//以图片为准
        if(sSmileyImgsArray == null){
            sSmileyImgsArray = getIntArray(PocApplication.getInstance().getApplicationContext(), R.array.smiley_resid_array);
        }
        
        EaseEmojicon[] datas = new EaseEmojicon[sSmileyImgsArray.length];
        for(int i = 0; i < sSmileyImgsArray.length; i++){
            datas[i] = new EaseEmojicon(sSmileyImgsArray[i], String.valueOf(sSmileyTextsArray[i]), Type.NORMAL);
        }
        return datas;
    }
    
    public static EaseEmojicon[] getData(){
        return DATA;
    }
    
    /**
	 * 获取arrays.xml中<integer-array name="id">
	 * 用Context.getResources().getIntArray(R.array.default_smiley_texts)
	 * 获取arrays.xml中<integer-array name="default_smiley_imgs">得到的数组都是为0，
	 * 用这个方法才可以正常获取
	 * 
	 * @param mContext
	 * @param intArrayId
	 * @return
	 */
	public static int[] getIntArray(Context mContext, int intArrayId) {
		TypedArray ta = mContext.getResources().obtainTypedArray(intArrayId);
		int len = ta.length();
		int[] intArray = new int[len];
		for (int i = 0; i < len; i++) {
			intArray[i] = ta.getResourceId(i, 0);
		}
		ta.recycle();
		return intArray;
	}
    
}
